﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DinoMessenger
{
    public partial class ChatForm : Form
    {
        private WSHandler WSHandler;
        private List<WSMessage> WSResponse;

        public ChatForm()
        {
            InitializeComponent();
            WSHandler = new WSHandler();
        }

        private void InsertMessage(String isMessage)
        {
            LogBox.Text = String.Concat(LogBox.Text, "\r\n", isMessage);
        }

        private void TimerRefresh_Tick(object sender, EventArgs e)
        {
            WSResponse = WSHandler.getMessages();
            
            foreach (WSMessage Message in WSResponse)
            {
                InsertMessage(Message.Text);
                System.Console.WriteLine("Message.Text: {0}", Message.Text);
            }
            
            //InsertMessage(WSResponse.Message.Count());
           
        }

        private void ButtonSend_Click(object sender, EventArgs e)
        {
            Boolean lbCrypted = false;

            WSHandler.SendMessage(InputBoxMessage.Text, lbCrypted);
            InsertMessage(InputBoxMessage.Text);
            InputBoxMessage.Text = "";
        }
    }
}
